package com.yanqu.road.server.cmd.activity.yearMaster;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.pb.yearMaster.YearMasterProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.yearMaster.YearMasterModule;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_YEAR_MASTER_CONSUME_GOODS, desc = "消耗道具")
public class YearMasterNotifyConsumeGoodsCmd extends AbstractCommand {


    int activityId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        YearMasterProto.YearMasterNotifyConsumeGoodsReqMsg reqMsg = YearMasterProto.YearMasterNotifyConsumeGoodsReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ActivityInfo activityInfo = NormalActivityMgr.getActivityInfo(activityId);
        if (null != activityInfo) {
            player.getModule(YearMasterModule.class).autoUseActivityGoods(activityInfo);
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
